package cn.tedu.mybatis.map;

import java.util.HashMap;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        String line = "i love java! thinking in java!! hello world!";
        Map<Character,Integer> map=new HashMap<>();
        for (int i = 0; i < line.length(); i++) {
            char c=line.charAt(i);
            if(map.containsKey(line.charAt(i)))
            {
                int num=map.get(line.charAt(i));
                num++;
                map.put(c,num);
            }else {
                map.put(c,1);
            }
        }
        System.out.println(map);
        map.forEach((k,v)-> System.out.println(k+":"+v));
    }
}
